package kr.pe.johnkim.carrotpoint.mobile.dao;

import kr.pe.johnkim.carrotpoint.mobile.domain.CarrotPointMerchantPayment;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Carrot Point 가맹점 결제 관련 dao 클래스 이다.
 *
 * @author : John_Kim <cale9797@gmail.com>
 * @date : 13. 2. 6.
 */
@Repository
public class CarrotPointMerchantPaymentDaoImpl extends SqlSessionDaoSupport implements CarrotPointMerchantPaymentDao {

    // SLF4J Logging
    private Logger logger = LoggerFactory.getLogger(CarrotPointMerchantPaymentDaoImpl.class);

    /**
     * 가맹점 결제를 등록 한다.
     *
     * @param carrotPointMerchantPayment
     */
    @Override
    public void registerMerchantPayment(CarrotPointMerchantPayment carrotPointMerchantPayment) {
        logger.info("registerMerchantPayment");
        this.getSqlSession().insert("CARROTPOINT_MERCHANT_PAYMENT.registerMerchantPayment", carrotPointMerchantPayment);
    }

    /**
     * 가맹점 결제 목록을 가져 온다.
     *
     * @param carrotPointMerchantPayment
     * @return
     */
    @Override
    public List<CarrotPointMerchantPayment> getMerchantPaymentList(CarrotPointMerchantPayment carrotPointMerchantPayment) {
        logger.info("getMerchantPaymentList");
        return this.getSqlSession().selectList("CARROTPOINT_MERCHANT_PAYMENT.getMerchantPaymentList", carrotPointMerchantPayment);
    }

    /**
     * 가맹점 결제 내용을 가져 온다.
     *
     * @param carrotPointMerchantPayment
     * @return
     */
    @Override
    public CarrotPointMerchantPayment getMerchantPaymentInformation(CarrotPointMerchantPayment carrotPointMerchantPayment) {
        logger.info("getMerchantPaymentInformation");
        return (CarrotPointMerchantPayment)getSqlSession().selectOne("CARROTPOINT_MERCHANT_PAYMENT.getMerchantPaymentInformation", carrotPointMerchantPayment);
    }

    /**
     * 가맹점 결제 내용을 업데이트 한다.
     *
     * @param carrotPointMerchantPayment
     */
    @Override
    public void updateMerchantPaymentInformation(CarrotPointMerchantPayment carrotPointMerchantPayment) {
        logger.info("updateMerchantPaymentInformation");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_PAYMENT.updateMerchantPaymentInformation", carrotPointMerchantPayment);
    }

    /**
     * 가맹점 결제를 배활성화 한다.
     *
     * @param carrotPointMerchantPayment
     */
    @Override
    public void updateDeactivateMerchantPayment(CarrotPointMerchantPayment carrotPointMerchantPayment) {
        logger.info("updateDeactivateMerchantPayment");
        this.getSqlSession().update("CARROTPOINT_MERCHANT_PAYMENT.updateDeactivateMerchantPayment", carrotPointMerchantPayment);
    }
}
